package a.f.j;

import a.c.bb;
import a.c.d;
import a.c.e;
import a.c.m;
import a.c.q;
import a.c.w;
import a.i.wb;

import java.util.ArrayList;

public class eb
{
  protected q a;
  protected boolean b;
  protected int[] c;
  protected boolean[] d;
  protected ArrayList e;
  protected ArrayList f;
  protected ArrayList g;
  protected wb h;
  protected long i = 1306737L;
  public static int j;
  
  public void a(q paramq)
  {
    this.a = paramq;
    this.c = new int[paramq.k()];
    this.d = new boolean[paramq.k()];
    this.e = new ArrayList(paramq.k());
    this.f = new ArrayList(paramq.k());
    this.g = new ArrayList(paramq.k());
    this.h = new wb(this.i);
  }
  
  public void a(boolean paramBoolean)
  {
    this.b = paramBoolean;
  }
  
  public void a(bb parambb)
  {
    boolean bool = ab.g;
    int k = ab.f;
    a();
    parambb.clear();
    this.e.clear();
    w localw = this.a.v();
    do
    {
      if (!localw.e()) {
        break;
      }
      this.e.add(localw.d());
      localw.f();
      if (bool) {
        break label103;
      }
      if (k != 0) {
        break label91;
      }
    } while (k == 0);
    if (!bool)
    {
      a(this.e, this.g);
      label91:
      if (!bool) {
        if (this.g.isEmpty()) {
          label103:
          throw new RuntimeException("Graph consists only of directed circles");
        }
      }
    }
    a(this.e, this.g, this.f, parambb);
    if (!this.e.isEmpty()) {
      a(this.f, this.g);
    }
    while (bool)
    {
      if (!bool) {
        if (this.g.isEmpty()) {
          a(this.e, this.g);
        }
      }
      if (!bool)
      {
        if (this.g.isEmpty()) {
          throw new RuntimeException("Graph contains a directed circle");
        }
        a(this.e, this.g, this.f, parambb);
      }
      if (k == 0) {
        break;
      }
    }
  }
  
  protected void a()
  {
    boolean bool = ab.g;
    int m = ab.f;
    int k = 0;
    if (k < this.a.j()) {
      this.c[k] = 0;
    }
    while (bool)
    {
      if (!bool)
      {
        if (m != 0) {
          break label58;
        }
        this.d[k] = false;
        k++;
      }
      if (m == 0) {
        break;
      }
    }
    label58:
    m localm = this.a.w();
    do
    {
      if (!localm.e()) {
        break;
      }
      d locald = localm.a();
      this.c[locald.f().f()] += 1;
      this.c[locald.e().f()] += 1;
      localm.f();
    } while (m == 0);
  }
  
  protected void a(ArrayList paramArrayList1, ArrayList paramArrayList2)
  {
    boolean bool = ab.g;
    int i1 = ab.f;
    paramArrayList2.clear();
    int k = 2147483647;
    int m = 0;
    do
    {
      if (m >= paramArrayList1.size()) {
        break;
      }
      e locale = (e)paramArrayList1.get(m);
      int n = this.c[locale.f()];
      if (!bool)
      {
        if (n < k)
        {
          k = n;
          paramArrayList2.clear();
        }
        if (bool) {}
      }
      else
      {
        if (n == k) {
          paramArrayList2.add(locale);
        }
        m++;
      }
    } while (i1 == 0);
  }
  
  public void a(ArrayList paramArrayList1, ArrayList paramArrayList2, ArrayList paramArrayList3, bb parambb)
  {
    boolean bool = ab.g;
    int n = ab.f;
    if (!bool) {}
    e locale1 = this.b ? a(paramArrayList2) : (e)paramArrayList2.get(0);
    int k = paramArrayList1.indexOf(locale1);
    if (!bool) {
      if (k >= 0) {
        paramArrayList1.remove(k);
      }
    }
    parambb.add(locale1);
    paramArrayList3.clear();
    this.d[locale1.f()] = true;
    m localm = locale1.l();
    do
    {
      if (!localm.e()) {
        break;
      }
      d locald = localm.a();
      e locale2 = locald.a(locale1);
      int m = locale2.f();
      if (!bool)
      {
        if (this.d[m] == 0)
        {
          this.c[m] -= 1;
          paramArrayList3.add(locale2);
        }
        localm.f();
      }
    } while (n == 0);
  }
  
  protected e a(ArrayList paramArrayList)
  {
    if (!ab.g) {
      if (paramArrayList.size() == 0) {
        throw new RuntimeException("Given an empty list!");
      }
    }
    int k = this.h.nextInt(paramArrayList.size());
    return (e)paramArrayList.get(k);
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.f.j.eb

 * JD-Core Version:    0.7.0.1

 */